/**
 * 
 */
package any.gwt.client.ui;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HasHTML;

/**
 * TODO: Doc me
 * 
 * @author keke <keke@codehaus.org>
 * @version
 * @revision $Revision:$
 */
public class SpanHTML extends Span implements HasHTML {

    /**
     * Creates an empty HTML widget.
     */
    public SpanHTML() {
        setElement(DOM.createSpan());
        sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS);
        setStyleName("spanHtml");
    }

    /**
     * Creates an HTML widget with the specified HTML contents.
     * 
     * @param html
     *            the new widget's HTML contents
     */
    public SpanHTML(final String html) {
        this();
        setHTML(html);
    }

    /**
     * Creates an HTML widget with the specified contents, optionally treating
     * it as HTML, and optionally disabling word wrapping.
     * 
     * @param html
     *            the widget's contents
     * @param wordWrap
     *            <code>false</code> to disable word wrapping
     */
    public SpanHTML(final String html, final boolean wordWrap) {
        this(html);
        setWordWrap(wordWrap);
    }

    public String getHTML() {
        return DOM.getInnerHTML(getElement());
    }

    public void setHTML(final String html) {
        DOM.setInnerHTML(getElement(), html);
    }

}
